<template>
  <v-card title="功能操作">
    <div class="mb-30">
      <div class="mb-5">
        <v-button-group>
          <v-button @click="$refs.xTable.showColumnModal()">列选择</v-button>
          <v-button @click="$refs.xTable.showFilterModal()">过 滤</v-button>
          <v-button @click="$refs.xTable.operateRestore()">还 原</v-button>
          <v-button @click="$refs.xTable.exportExcel()">导 出</v-button>
          <v-button @click="$refs.xTable.emptyTableLists()">清空数据</v-button>
          <v-button @click="handleTable">测试</v-button>
        </v-button-group>
      </div>
      <vcu-table
        :checkbox-config="{
          checkMethod: activeRowMethod,
          checkRowKeys: defaultSelecteRows,
        }"
        row-id="ZYID00"
        :columns="tableColumns"
        :exportExcelUrl="exportExcelUrl"
        :filterFormData="filterFormData"
        :loadOptions="options"
        @onHeaderLoad="onHeaderLoad"
        @onPageLoad="onPageLoad"
        beforePageLoad
        customModalShow
        filterModalShow
        locking
        ref="xTable"
        :height="500"
      ></vcu-table>
    </div>
  </v-card>
</template>
<script>
import XEUtils from "xe-utils";
export default {
  data() {
    return {
      options: {
        headUrl: "colspan/datas/header", //"dataq/api/header/locationbug",
        pageUrl: "colspan/datas/page", //"dataq/api/page/locationbug",
        checkbox: true,
      },
      exportExcelUrl: "http://10.16.241.70:8089/dataq/export/getInHospPatientList",
      filterFormData: {
        filterFindUrl: "getInHospPatientList4cy",
        operationUrl: "dataq/api/dict/operation", //正式环境不需要
        relationUrl: "dataq/api/dict/relation", //正式环境不需要
        filterFindFormData: {
          deptNo: "14",
        },
      },
      filterFormData1: {
        filterFindUrl: "getInHospPatientList4cy",
        operationUrl: "dataq/api/dict/operation", //正式环境不需要
        relationUrl: "dataq/api/dict/relation", //正式环境不需要
        filterFindFormData: {
          deptNo: "14",
        },
      },
      tableColumns: [],
      defaultSelecteRows: [],
    };
  },
  mounted() {},
  methods: {
    onHeaderLoad(res) {
      this.tableColumns = XEUtils.mapTree([...res], (item) => {
        if (item.key == "YX0000" || item.fatherKey == "YX0000" || item.key == "C_GJHJ" || item.key == "C_LSHJ") {
          item.hidden = true;
          item.visible = false;
        }
        return { ...item };
      });
    },
    onPageLoad({ datas, count, response }) {
      console.info(datas, count, response);
      this.defaultSelecteRows = ["271265"];
      //this.$refs.xTable.reloadData(datas);
    },
    activeRowMethod({ row }) {
      return row.ZYID00 != "271265";
    },
    handleTable() {
      this.options.headUrl = "dataq/api/header/locationbug";
      console.info(this.$refs.xTable.getCheckboxRecords());
    },
  },
};
</script>
